//
//  AccountBackground.m
//  ArtCircle
//
//  Created by sunbin on 2017/5/18.
//  Copyright © 2017年 Quanli. All rights reserved.
//

#import "AccountBackground.h"


@interface AccountBackground()


@end

@implementation AccountBackground


-(AuthorizedLogin *)authorizedLoginView {

    if (!_authorizedLoginView) {
        _authorizedLoginView = [[AuthorizedLogin alloc] init];
        [self addSubview:_authorizedLoginView];
    }
    return _authorizedLoginView;
}


- (AccountHeader *)accountHeaderView {
    if (!_accountHeaderView) {
        _accountHeaderView = [[AccountHeader alloc] init];
        [self addSubview:_accountHeaderView];
    }
    
    return _accountHeaderView;
}


- (InputBox *)inputBoxView {
    if (!_inputBoxView) {
        _inputBoxView = [[InputBox alloc] init];
        _inputBoxView.backgroundColor = [UIColor grayColor];
        [self addSubview:_inputBoxView];
    }

    return _inputBoxView;
}




- (void)awakeFromNib {

    [super awakeFromNib];
    
//    self.layer.contents = (id) PNGkImg(@"").CGImage;

}




- (void)layoutSublayersOfLayer:(CALayer *)layer{
    [super layoutSublayersOfLayer:layer];
    

}

- (void)drawRect:(CGRect)rect {
    
    
    // 设置约束
    WEAKSELF;
    
    [self.accountHeaderView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(weakSelf.mas_centerX);
        make.left.equalTo(weakSelf.mas_left).with.offset(0);
        make.top.equalTo(weakSelf.mas_top).with.offset(0);
        
        make.height.mas_equalTo(@100);

    }];
    
    self.accountHeaderView.backgroundColor = [UIColor whiteColor];
    if ([self.delegate respondsToSelector:@selector(isShowAccountHeaderView)]) {

        self.accountHeaderView.hidden =  ![self.delegate isShowAccountHeaderView];
    }

    
    [self.authorizedLoginView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(weakSelf.mas_centerX);
        make.left.equalTo(weakSelf.mas_left).with.offset(0);
        make.bottom.equalTo(weakSelf.mas_bottom).with.offset(0);
        
        make.height.mas_equalTo(@200);
    }];
    
    self.authorizedLoginView.backgroundColor = [UIColor blackColor];
    
    if ([self.delegate respondsToSelector:@selector(isShowAuthorizedLoginView)]) {
        
        self.authorizedLoginView.hidden =  ![self.delegate isShowAuthorizedLoginView];
    }
    

    
    [self.inputBoxView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.mas_left).with.offset(0);
        make.right.equalTo(weakSelf.mas_right).with.offset(0);

        make.bottom.equalTo(weakSelf.authorizedLoginView.mas_top).with.offset(0);
        make.top.equalTo(weakSelf.accountHeaderView.mas_bottom).with.offset(0);

    }];
    

    if ([self.delegate respondsToSelector:@selector(getInputBoxType)]) {
        weakSelf.inputBoxView.ty = [self.delegate getInputBoxType];
    }
    
    
    
}




@end
